#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
#define pdd pair<double,double>
int T,n,m;
double l,vm;
bool vis[N];
double tev[N];

struct node{
    bool isover;
    double v0,a,bg,overplace;
}car[N];

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>T;
    while(T--){
        bool p1=true,p2=true;
        cin>>n>>m>>l>>vm;
        for(int i=1;i<=n;i++){
            cin>>car[i].bg>>car[i].v0>>car[i].a;
            if(car[i].a!=0) p1=false;
            if(car[i].a<=0) p2=false;
        }
        for(int i=1;i<=m;i++) cin>>tev[i];
        if(p1){
            int cnt=0;
            for(int i=1;i<=n;i++){
                if(car[i].v0>vm&&car[i].bg<=tev[m]) cnt++;
            }
            cout<<cnt<<' ';
            if(cnt>0)cout<<m-1<<"\n";
            else cout<<m<<"\n";
            continue;
        }
        else if(p2){
            int cntover=0;
            for(int i=1;i<=n;i++){
                if(car[i].v0>vm) car[i].overplace=car[i].bg;
                else if(car[i].v0==vm) car[i].overplace=car[i].bg+0.00001;
                else car[i].overplace=car[i].bg+(vm*vm-car[i].v0*car[i].v0)/(2*car[i].a)+0.00001;
                if(car[i].overplace<=tev[m]) cntover++;
            }
            cout<<cntover<<' ';
            if(cntover>0) cout<<m-1<<"\n";
            else cout<<m<<"\n";
        }
        else{
            priority_queue<pdd,vector<pdd>,greater<pdd> > q;
            int cntover=0;
            for(int i=1;i<=n;i++){
                if(car[i].v0<=vm) continue;
                int pos=lower_bound(tev+1,tev+1+m,car[i].bg)-tev;
                if(pos>m) continue;
                if(tev[pos]<car[i].bg+(vm*vm-car[i].v0*car[i].v0)/(2*car[i].a)){
                    car[i].isover=true;
                    cntover++;
                    q.push({car[i].bg,car[i].bg+(vm*vm-car[i].v0*car[i].v0)/(2*car[i].a)});
                }
            }
            int p=1,left=0;
            while(!q.empty()){
                pdd h=q.top();
                q.pop();
                while(tev[p]<h.first&&p<=m) p++;
                while(tev[p+1]<h.second&&p+1<=m) p++;
                left++;
                while(q.top().first<=tev[p]&&tev[p]<q.top().second) q.pop();
            }
            cout<<cntover<<' '<<m-left<<"\n";
        }
    }
    return 0;
}
/*
        for(int i=1;i<=n;i++){
            if(car[i].a==0){
                if(car[i].v0<=vm) continue;
                cntarea++;
                vis[cntarea]=false;
                area[cntarea]={car[i].bg,l};
            }
            if(car[i].a<0){
                if(car[i].v0<=vm) continue;
                cntarea++;
                vis[cntarea]=false;
                area[cntarea]={car[i].bg,car[i].bg+(vm*vm-car[i].v0*car[i].v0)/(2*car[i].a)};
            }
            else{
                if(car[i].v0>vm)
            }
        }
*/
/*
2996 863
2994 285
2991 292
2995 2880
2982 2137
2999 2680
2995 2540
2986 1457
2929 1919
2997 2547
99691 35478
99987 68384
99335 81601
98570 49067
100000 88807
99990 35942
99900 65610
99981 44819
99999 18514
99955 92874
*/
